
distance=40
filetoimport=paste("Derived Data/dfbartik2005_",distance,"kmanalysis_annual.csv",sep="")

dfbartik=fread(filetoimport)

# Full Sample: Grades 4-8, 2009-10 to 2017-18 
dfout=dfbartik  %>% drop_na(cs_mn_all,avgpm25_9, cs_mn_all_lag_cohort,pctutility2005,pctemploy2005, pctsinglemother2005,pctmanufac2005, pctutility2005, pctbachelorhigher2005, pct_hisp_2005,pct_male_2005,enroll_2005,pct_ell_2005,pct_speced_2005,pct_FRPM_2005, pct_black_2005, pct_white_2005)

nrow(dfout)

length(unique(dfout$leaid))

mean(dfout$avgpm25_9,na.rm=TRUE)

mean(dfout$perblk,na.rm=TRUE)

mean(dfout$perhsp,na.rm=TRUE)

mean(dfout$perasn,na.rm=TRUE)


mean(dfout$perwht,na.rm=TRUE)


mean(dfout$perell,na.rm=TRUE)

mean(dfout$perspeced,na.rm=TRUE)

mean(dfout$cs_mn_all,na.rm=TRUE)

mean(dfout$cs_mn_all_lag_cohort,na.rm=TRUE)


mean(dfout$perfrl,na.rm=TRUE)

######################################
# only spring testing 

dfout=dfout[dfout$testmonth=="May",]

nrow(dfout)

length(unique(dfout$leaid))


mean(dfout$avgpm25_9,na.rm=TRUE)

mean(dfout$perblk,na.rm=TRUE)

mean(dfout$perhsp,na.rm=TRUE)

mean(dfout$perasn,na.rm=TRUE)


mean(dfout$perwht,na.rm=TRUE)


mean(dfout$perell,na.rm=TRUE)

mean(dfout$perspeced,na.rm=TRUE)

mean(dfout$cs_mn_all,na.rm=TRUE)

mean(dfout$cs_mn_all_lag_cohort,na.rm=TRUE)


mean(dfout$perfrl,na.rm=TRUE)

#################################

dfout=dfout[!is.na(dfout$bartikleave_40),]

nrow(dfout)

length(unique(dfout$leaid))


mean(dfout$avgpm25_9,na.rm=TRUE)
mean(dfout$perblk,na.rm=TRUE)

mean(dfout$perhsp,na.rm=TRUE)

mean(dfout$perasn,na.rm=TRUE)


mean(dfout$perwht,na.rm=TRUE)

mean(dfout$perecd,na.rm=TRUE)

mean(dfout$perell,na.rm=TRUE)

mean(dfout$perspeced,na.rm=TRUE)

mean(dfout$cs_mn_all,na.rm=TRUE)

mean(dfout$cs_mn_all_lag_cohort,na.rm=TRUE)


mean(dfout$perfrl,na.rm=TRUE)
